﻿using OperationPlugins;
using OperationPlugins.Validators;
using TimeProject.Engine;
using TimeProject.Validators.Utils;
using TimeProject.WebSite.ViewModels;

namespace TimeProject.Validators.ViewModels.Level2
{
    [ValidatorOf(ValidationLevel.Level2, typeof(RegisterViewModel))]
    [OperationFilter(TimeProjectOperations.Register)]
    public class RegisterViewModelValidator : TimeProjectValidatorBase<RegisterViewModel>
    {
        protected override void Validate()
        {
            PassIfTrue(Value.AcceptLicence, "You must accept the licence agreement!");

            if (string.IsNullOrEmpty(Value.EMail) == false)
            {
                PassIfTrue(StringUtil.IsWellFormedEmail(Value.EMail), "Given e-mail address is not well-formed.");
            }
        }
    }
}
